import os

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'jkv)qke3_b$2r7@@%wcde8#)r+v@ug@77r@or#5u^lq^lh&oxm'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

ALLOWED_HOSTS = []


# Application definition

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'app01',
    'web',

]

MIDDLEWARE = [
    'django.middleware.security.SecurityMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
    # 认证中间件
    'web.middleware.auth.AuthMiddleware',
]

ROOT_URLCONF = 's25.urls'

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [os.path.join(BASE_DIR,"templates")],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
            ],
        },
    },
]

WSGI_APPLICATION = 's25.wsgi.application'


# Database
# https://docs.djangoproject.com/en/3.0/ref/settings/#databases

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': '数据库名',
        'PASSWORD': '11111111',
        'USER': 'lanyc',
        'HOST': 'x.x.x.x',
    }
}



AUTH_PASSWORD_VALIDATORS = [
    {
        'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
    },
]


# Internationalization
# https://docs.djangoproject.com/en/3.0/topics/i18n/

LANGUAGE_CODE = 'zh-hans'

TIME_ZONE = 'Asia/Shanghai'

USE_I18N = True

USE_L10N = True

USE_TZ = True


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/3.0/howto/static-files/

STATIC_URL = '/static/'
STATICFILES_DIRS = [os.path.join(BASE_DIR,'static')]

#########腾讯云短信
TENCENT_SMS_TEMPLATE = {
    # 注册
    "register":111111111111,
    # 登录
    "login":1111111111111,
    # 修改密码
    "resetpassword":1111111111111,
}

APPID = 1111111111
APPKEY = '111111111111111111111111'
SMSSIGN = '花脚乌龟'

################腾讯云存储cos
COS_SECRET_ID = 'AKID2pAF5eszm0xpjMivpTqqa4HuGPHsJ4HE'
COS_SECRET_KEY = 'qPlrihRzGHI6ewxhHbey1uoUffPsEKHy'

####################################################连接redis
CACHES = {
    "default": {
        "BACKEND": "django_redis.cache.RedisCache",
        "LOCATION": "redis://1.1.1.1:6379", # 安装redis的主机的 IP 和 端口
        "OPTIONS": {
            "CLIENT_CLASS": "django_redis.client.DefaultClient",
            "CONNECTION_POOL_KWARGS": {
                "max_connections": 1000,
                "encoding": 'utf-8'
            },
            "PASSWORD": "111111111111" # redis密码
        }
    },
    # 如果你需要用连接池连上多台redis节点，以后你在做主从读写分离，就会用到这个，get_redis_connection中的参数，就是
    # 按照这个redis名，default或者master在视图中就能直接使用这里连接好的
    #  "master": {
    #     "BACKEND": "django_redis.cache.RedisCache",
    #     "LOCATION": "redis://1.1.1.1:6379", # 安装redis的主机的 IP 和 端口
    #     "OPTIONS": {
    #         "CLIENT_CLASS": "django_redis.client.DefaultClient",
    #         "CONNECTION_POOL_KWARGS": {
    #             "max_connections": 1000,
    #             "encoding": 'utf-8'
    #         },
    #         "PASSWORD": "password" # redis密码
    #     }
    # }
}

# ########### 登录白名单：无需登录就可以访问的页面 ###########
WHITE_REGEX_URL_LIST = [
    "/",
    "/register",
    "/sms",
    "/login",
    "/login/sms",
    "/image_code",
    "/index",
    "/price",
    "/user/active",
]

#######################支付宝配置
APPID_ALIPAY = "你的支付宝APPID"
# 这是支付宝的沙箱网关，正式支付环境把dev去掉
ALIPAY_GATEWAY = "https://openapi.alipaydev.com/gateway.do"
# 支付宝公钥(路径)，这两个一定记得加前后缀(begin,end)
ALIPAY_PUBLIC_PATH = os.path.join(BASE_DIR, 'keys/alipay_public_key.pem')
# 支付宝私钥(路径)，到时候要用一下read读出来
APP_PRIVATE_PATH = os.path.join(BASE_DIR, 'keys/app_private_key.pem')
NOTIDY_URL = "http://127.0.0.1:8000/pay/notify"  # 必须得是公网，不能是开发服务器127.0.0.1
RETURN_URL = "http://127.0.0.1:8000/pay/return"  # 之所以GET能跳转是因为这个get请求是基于js的，


#####################django的发邮件配置
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' # 固定写法
EMAIL_HOST = 'smtp.qq.com' # QQ的SMTP地址,是163邮箱则换为smtp.163.com
EMAIL_PORT = 25 # SMTP端口
EMAIL_HOST_USER = 'aaaaaa@qq.com' #发送邮件的邮箱
EMAIL_HOST_PASSWORD = 'aaaaaaaaaaaaa'  # 授权码，qq邮箱中发短信后获取到的
# 发件人，<>里面的东西必须和EMAIL_HOST_USER（目的邮箱地址一摸一样，不能随便写，不然邮件发不出去）
EMAIL_FROM = '买了佛冷<aaaaaa@qq.com>'


############服务器ip（rabbitmq使用）
SERVER_IP = 'x.x.x.x'


try:
    from .local_settings import *
except ImportError:
    pass
